package com.haoze.nurse.controller;

import com.haoze.common.response.Result;
import com.haoze.nurse.params.ChapApproveParam;
import com.haoze.nurse.params.ChapTempParam;
import com.haoze.nurse.params.ChaperonageParam;
import com.haoze.nurse.service.ChaperonageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping(value = "/nurse/chapmanage")
@Api(value = "陪护管理")
public class ChapManageController {

    @Resource
    ChaperonageService chaperonageService;

    @PostMapping("/addChaperonage")
    @ApiOperation(value = "新增陪护")
    public Result addChaperonage(@RequestBody ChaperonageParam param) {
        return chaperonageService.addChaperonage(param);
    }

    @PostMapping("/editChaperonage")
    @ApiOperation(value = "编辑陪护申请")
    public Result editChaperonage(@RequestBody ChaperonageParam param) {
        return chaperonageService.editChaperonage(param);
    }

    @GetMapping("/patientInfo")
    @ApiOperation(value = "获取患者信息")
    public Result patientInfo(@RequestParam String inpatNum,
                              @RequestParam(required = false) String patName) {
        return chaperonageService.patientInfo(inpatNum, patName);
    }

    @GetMapping("/oneChap")
    @ApiOperation(value = "单条陪护申请")
    public Result oneChap(@RequestParam String chapId) {
        return chaperonageService.oneChap(chapId);
    }
    
    @GetMapping("/list")
    @ApiOperation(value = "获取陪护列表")
    public Result chaperonageList(@RequestParam(defaultValue = "1") Integer page,
                                  @RequestParam(defaultValue = "50") Integer pageSize,
                                  @RequestParam String wardId,
                                  @RequestParam String beginTime,
                                  @RequestParam String endTime) {
        return chaperonageService.chaperonageList(page, pageSize, wardId, beginTime, endTime);
    }

    @PostMapping("/approveChap")
    @ApiOperation(value = "审批陪护申请")
    public Result approveChap(@RequestBody ChapApproveParam param) {
        return chaperonageService.approveChap(param);
    }

    @PostMapping("/addChapTemp")
    @ApiOperation(value = "添加陪护人员体温")
    public Result addChapTemp(@RequestBody ChapTempParam param) {
        return chaperonageService.addChapTemp(param);
    }

    @GetMapping("/delChapTemp")
    @ApiOperation(value = "删除陪护人员体温")
    public Result delChapTemp(@RequestParam String chapTempId) {
        return chaperonageService.delChapTemp(chapTempId);
    }

    @GetMapping("/chapStatus")
    @ApiOperation(value = "陪护统计")
    public Result chapStatus() {
        return chaperonageService.chapStatus();
    }

    @GetMapping("/tempHistory")
    @ApiOperation(value = "获取体温历史")
    public Result tempHistory(@RequestParam String chapId,
                              @RequestParam(required = false) String beginDate,
                              @RequestParam(required = false) String endDate) {
        return chaperonageService.tempHistory(chapId, beginDate, endDate);
    }

    @GetMapping("/chapCardTempList")
    @ApiOperation(value = "陪护卡关联体温录入列表")
    public Result chapCardTempList(@RequestParam String wardId) {
        return chaperonageService.chapCardTempList(wardId);
    }

    @GetMapping("/exportTempExcel")
    @ApiOperation(value = "导出体温excel")
    public ResponseEntity<byte[]> exportTempExcel(@RequestParam String wardId,
                                                  HttpServletResponse response) {
        return chaperonageService.exportTempExcel(wardId, response);
    }

    @GetMapping("/getRoles")
    @ApiOperation(value = "获取角色-判断护士或护士长")
    public Result getRoles() {
        return chaperonageService.getRoles();
    }
}
